Datapolis Process System SDK
Activity Code
Below you will find basic information about coding activity in Datapolis Process System.
Requirements
For coding function you need to have in your project references to:
Implementation
public
class
WBCreateListActivity : WBActivityBase
{
//...
}
Parameters Registration
An activity can have some number of properties. Each parameter is defined in xml and it should be registered in code. The following pattern is used for parameter registration:
DependencyProperty property = DependencyProperty.Register([Name], [PropertyType], [OwnerType]);
The Datapolis Process System activity supports (from Workbox 1.5) the property types like below:
In the parameter definition there is used OwnerType (createListType in the provided example) - it is just type of an activity.
A few examples displaying parameters registration is shown as follow:
private
static
readonly
Type createListType =
typeof
(WBCreateListActivity);
DependencyProperty ParentWebUrlProperty = DependencyProperty.Register(
"ParentWebUrl"
,
(
string
), createListType);
DependencyProperty IsQuickLuanchProperty = DependencyProperty.Register(
"IsQuickLuanch"
bool
?), createListType);
Define the Activity Properties
The implementation of activity property is a bit different from the implementation of regular class property. The dependency property accessors methods: get and set use the base class methods: GetValue and SetValue appropriately. Such as implementation is necessary from Datapolis Process System Designer point of view.
The additional aspect of coding the activity properties is to indicate which property should be required and which one not. By settings the proper ValidationOption attribute impacts on Datapolis Process System Designer behaviour and rendering related to the activity property. It is a way to manage if the given activity property should be required or not.
This example shows the activity properties coding in practice:
[ValidationOption(ValidationOption.Required)]
ParentWebUrl
get
return
)
base
.GetValue(ParentWebUrlProperty); }
set
.SetValue(ParentWebUrlProperty, value); }
[ValidationOption(ValidationOption.Optional)]
IsQuickLuanch
? quickLaunch = (
?)
.GetValue(IsQuickLuanchProperty);
if
(quickLaunch !=
null
&& quickLaunch.HasValue)
quickLaunch.Value;
false
;
.SetValue(IsQuickLuanchProperty, value); }
Verify Activity Properties and Parameter Registration
After finishing above two points verify that all parameters names are correct and same in every place. Please see below example:
DependencyProperty SomeNameProperty = DependencyProperty.Register(
"SomeName"
SomeName
.GetValue(SomeNameProperty); }
.SetValue(SomeNameProperty, value); }
Parameters must be also specified in XML, see next step for more details.
<
Parameters
>
Parameter
Name
=
Coding the Activity Business Logic
In order to develop the activity business logic it is needed to override the ExecuteBody method. Now, Datapolis Process System workflow system requires activity to always return the ActivityExecutionStatus.Closed activity execution status. The developer who builds an activity determines whether the activity execution breaks the workflow process or not. Additionally, any data occurred during the activity execution could be traced by WBLogger. For more details see Trace Logging
This example creates a list during the activity execution. When this process is broken (e.g. the list with the same name already exists) the appropriate message will be logged and the workflow process is being continued.
protected
override
ActivityExecutionStatus ExecuteBody(ActivityExecutionContext c)
this
.Logger.Verbose(
"Starting ExecuteBody function of the create list activity"
);
try
.CreateList();
catch
(Exception e)
.ErrorStatus = e.Message;
.ReturnListUrl =
.Empty;
.Logger.Unexpected(
"An error occured during creation a new list"
, e);
"Ending ExecuteBody function of the create list activity"
ActivityExecutionStatus.Closed;
When code part is done you can move to the next step, i.e. preparing Activity XMLs which will determine what the activity looks like and how it behaves in Datapolis Designer.